define(["./superController", "model/menuModel", "view/menuView", "common/data"], function(SuperController, MenuModel, MenuView, data){
	var MenuController = function(){

	}
	Func.extend(MenuController, SuperController);

	MenuController.prototype.createMenu = function(){
		var menuView = this.getView();

		this.getModel().getMenuData().done(function(data){
			menuView.createMenu(data.data);
		});
	}

	MenuController.prototype.bindEvent = function(){
		var that = this;
		// 顶部导航事件代理
		Func.bindEvent(document.getElementById("mainMenuList"), "click", function(event){
			var target = event.target || event.srcElement;
			that.getView().changeMenuState(target);
			that.getView().createLeftMenu(target.getAttribute("data-index"));
		});

		// 左侧导航事件代理
		Func.bindEvent(document.getElementById("leftMenuList"), "click", function(event){
			var target = event.target || event.srcElement;
			that.getView().changeMenuState(target);
			data.setHTML(target.getAttribute("data-url"));
		});
	}

	MenuController.prototype.init = function(){
		this.setModel(new MenuModel());
		this.setView(new MenuView());
		this.bindEvent();
	}

	return MenuController;
});